<input type="hidden" id="new_poll_status" value="<?php echo $this->session->flashdata('new_poll_status'); ?>" />
<script type="text/javascript">
  $(document).ready(function() {
    var new_poll_status = $.trim($('#new_poll_status').val());
    if (new_poll_status == 2) {
      toastr.error('Error occured. Try again !');
      return false;
    }
  });
</script>

<div class="page" style="min-height: 500px;">
  <div class="page-container">
    <div class="container">
      <div class="row">
        <div class="span12 header">
          <div class="btn-group pull-right">
            <a href="<?php echo base_url('polls'); ?>" class="btn pull-right">View Polls</a>
          </div>
          <h4>New poll</h4>
        </div>
        <div class="span12">
          <form method="post" action="<?php echo base_url('polls/create'); ?>" class="form-horizontal" onsubmit="return confirm_action('Save & publish poll ?');">
            <input type="hidden" name="csrf_token" value="<?php echo set_csrf_token(); ?>"/>
            <input type="hidden" id="poll_options_count" value="2" />
            <div class="control-group">
              <label class="control-label">Poll message</label>
              <div class="controls">
                <input name="poll_message" id="poll_message" type="text" style="width: 98%;" placeholder="Poll message (250)" value="" maxlength="250"/>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Poll options</label>
              <div class="controls">
                <input name="poll_options[]" id="poll_option_1" type="text" style="width: 49%;" placeholder="Option #1" value="" maxlength="250"/>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label"></label>
              <div class="controls">
                <input name="poll_options[]" id="poll_option_2" type="text" style="width: 49%;" placeholder="Option #2" value="" maxlength="250"/>
              </div>
            </div>
            <div id="add_more_option"></div>
            <div class="control-group">
              <label class="control-label"></label>
              <div class="controls">
                <a style="text-decoration: none; cursor: pointer;" onclick="return add_poll_option_create();">Add</a> | <a onclick="return remove_poll_option_create();" style="text-decoration: none; cursor: pointer;">Remove</a>
              </div>
            </div>
            <div class="control-group"> 
              <label class="control-label">Show voted users</label>
              <div class="controls">
                <input class="checkbox" checked="checked" type="checkbox" name="poll_show_users" value="1"/>
                <span class="text-warning" style="margin-left: 10px;">[ Allow others to view voted users for each option ]</span>
              </div>
            </div>
            <div class="control-group"> 
              <label class="control-label">Allow user options</label>
              <div class="controls">
                <input checked="checked" type="checkbox" name="poll_add_option" value="1"/>
                <span class="text-warning" style="margin-left: 10px;">[ Allow users to add new option and vote ]</span>
              </div>
            </div>
            <div class="control-group"> 
              <div class="controls">
                <button type="submit" class="btn" onclick="return validate_poll();">Create</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>